package nakedb.sql2xml;

/**
 * Model of a SQL Foreign Key.
 * 
 * @author Ro
 */
public class ForeignKey {
  private String sourceTable;
  private String sourceAttribute;
  private String targetTable;
  private String targetAttribute;
  
  /**
   * Creates a new Foreign Key.
   * 
   * @param sourceTable
   * @param sourceAttribute
   * @param targetTable
   * @param targetAttribute
   */
  public ForeignKey(String sourceTable, String sourceAttribute, 
      String targetTable, String targetAttribute) {
    this.sourceTable = sourceTable;
    this.sourceAttribute = sourceAttribute;
    this.targetTable = targetTable;
    this.targetAttribute = targetAttribute;
  }
  
  /**
   * Converts the Foreign Key to XML.
   * 
   * @return The XML representation of the Foreign Key.
   */
  public String toXml() {
    return String.format("<edge source=\"%s\" target=\"%s\"></edge>\n", 
        sourceTable, targetTable);
  }
}
